Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tooltip focus on mousemove #3335

Merged
merged 14 commits into from
May 28, 2020

Conversation

adfaris
Copy link
Contributor

@adfaris adfaris commented Apr 16, 2020

Summary

Resolves #2560

When a tooltip is opened via tab focus, any mouse movement will now close it. There will not be two tooltips opened at the same time.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
    - [ ] Checked in IE11 and Firefox
    - [ ] Props have proper autodocs
    - [ ] Added documentation examples
    - [ ] Added or updated jest tests
    - [ ] Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link

cla-checker-service bot commented Apr 16, 2020

💚 CLA has been signed

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cchaos
Copy link
Contributor

cchaos commented Apr 16, 2020

👋 Welcome, @adfaris! Can you please sign the CLA? Be sure to sign it with the same email address as your github account.

Be sure to also checkout our Contributing guide.

@adfaris
Copy link
Contributor Author

adfaris commented Apr 16, 2020

👋 Welcome, @adfaris! Can you please sign the CLA? Be sure to sign it with the same email address as your github account.

Be sure to also checkout our Contributing guide.

Hi @cchaos,

Thank you for the warm welcome.

I just verified my email settings on GitHub and resigned the form. No updates yet.

@adfaris
Copy link
Contributor Author

adfaris commented Apr 16, 2020

👋 Welcome, @adfaris! Can you please sign the CLA? Be sure to sign it with the same email address as your github account.
Be sure to also checkout our Contributing guide.

Hi @cchaos,

Thank you for the warm welcome.

I just verified my email settings on GitHub and resigned the form. No updates yet.

Nevermind, it worked. Thanks

@cchaos
Copy link
Contributor

cchaos commented Apr 16, 2020

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/

@adfaris
Copy link
Contributor Author

adfaris commented Apr 16, 2020

Test passed locally and should pass in CI now.

@@ -223,6 +223,7 @@ export class EuiToolTip extends Component<Props, State> {
hasFocus: true,
});
this.showToolTip();
window.addEventListener('mousemove', this.hasFocusMouseMoveListener);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, my main concern is adding this handler to hide the tooltip on any mouse movement. Example:

Screen Recording 2020-04-16 at 04 34 PM

It means that if the element that has a tooltip is interact-able (can have a focus state) and is focused, the tooltip disappears almost immediately when clicked on because of any slight movement with the mouse. It can just be a bit funky to interact with.

I offer this worry, but without a solid solution. Like a global tooltip service that manages the number of tooltips visible, which sounds like a headache from a system point of view. Or if #2560 is truly an issue that arises often or an issue at all.

Copy link
Contributor Author

@adfaris adfaris Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior for mousing over is not changed. It only listens for and closes the tooltip on any mousemove when the tooltip is opened via tabbing onto it on the keyboard.

When I view this in the build for this PR: https://eui.elastic.co/pr_3335/#/display/badge, the tooltip only closes on mouseout, like before, not on any mousemove.

I figured that this was the only practical solution, because switching from using a keyboard to a mouse seems appropriate to close a tooltip. I also think that a global registry may be more headache than it's worth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This event listener is added in the onFocus method which is only called when it is entered via keyboard tab.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, totally understand. However, you can enter the focus state with a mouse as well. For instance, if the anchoring element is just a toggle or a switch and doesn't actually navigate the user anywhere. Once the user clicks on the anchor (switch), any subsequent movement will close the tooltip.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Thanks.

Maybe we can be more specific on the event handler by applying the event listener only if it was a focus event with the tab key index as well. Thoughts?

@adfaris
Copy link
Contributor Author

adfaris commented Apr 21, 2020

@cchaos. Please re-review when you get a chance. I have made the necessary changes and everything is working.

@cchaos
Copy link
Contributor

cchaos commented Apr 23, 2020

Jenkins, test this

@adfaris
Copy link
Contributor Author

adfaris commented Apr 23, 2020

Build is failing because it can't install yarn.

@cchaos
Copy link
Contributor

cchaos commented Apr 23, 2020

retest

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/

@cchaos
Copy link
Contributor

cchaos commented May 13, 2020

Hi again @adfaris. Sorry for the extremely late response on this one. I've been going back and forth in my head whether the combination of keyboard tabbing and mousing around would be normal practice or if it would be odd to see the tooltip disappear when doing so.

Eventually I've landed on, no, I don't think this is a common case nor would it look unintended. So in that regard, I think this is a good final solution 💯

I think all it needs now is a Changelog entry since this does effect the shipped components.

@adfaris
Copy link
Contributor Author

adfaris commented May 15, 2020

The CHANGELOG has been updated.

@adfaris adfaris requested a review from cchaos May 15, 2020 14:37
@cchaos
Copy link
Contributor

cchaos commented May 15, 2020

Thanks @adfaris, looks like you'll need to rebase with master since there's been several releases and the changelog is out of date.

@cchaos
Copy link
Contributor

cchaos commented May 15, 2020

Hmm, that rebase didn't go so well, I'll get it cleaned up for you.

@cchaos cchaos force-pushed the tooltip-to-close-with-mouse-move branch from 6be9742 to ea1a6fa Compare May 15, 2020 18:49
cchaos added 2 commits May 15, 2020 14:51
@cchaos
Copy link
Contributor

cchaos commented May 15, 2020

retest

src/components/tool_tip/tool_tip.tsx Outdated Show resolved Hide resolved
src/components/tool_tip/tool_tip.tsx Show resolved Hide resolved
src/components/tool_tip/tool_tip.tsx Outdated Show resolved Hide resolved
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/

@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave this another run through on the docs to double check and found that the tooltip is disabled for keyboard users after it is triggered by the mouse

tooltip disappearance act

@adfaris adfaris force-pushed the tooltip-to-close-with-mouse-move branch from 7fdac01 to dca4496 Compare May 22, 2020 18:05
@adfaris
Copy link
Contributor Author

adfaris commented May 22, 2020

Gave this another run through on the docs to double check and found that the tooltip is disabled for keyboard users after it is triggered by the mouse

tooltip disappearance act

@chandlerprall

Please re-review it when you get a chance. The bug has been fixed.

@adfaris adfaris requested a review from chandlerprall May 22, 2020 18:09
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, will merge on green CI. Thanks @adfaris !

@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/

@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3335/

@chandlerprall chandlerprall merged commit fd3dd84 into elastic:master May 28, 2020
cchaos pushed a commit to cchaos/eui that referenced this pull request Aug 23, 2021
This reverts commit fd3dd84.

# Conflicts:
#	CHANGELOG.md
#	src/components/tool_tip/tool_tip.tsx
cchaos added a commit that referenced this pull request Aug 24, 2021
…orce visibility while element is focused (#5066)

* Revert "Remove tooltip focus on mousemove (#3335)"
* Applying `onFocus` and `onBlur` methods to child clone
* Put default value for `display` in `defaultProps` so it populates in the props table
* [EuiIconTip] Removing `children` from TS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple tooltip visibility
4 participants